<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="" />
<meta name="author" content="ChongMing" />
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="full-screen" content="yes">
<meta name="screen-orientation" content="portrait">
<meta name="x5-fullscreen" content="true">
<meta name="360-fullscreen" content="true">
<title>指定医生</title>
</head>
<link rel="stylesheet" href="../css/framework7.ios.min.css">
<link rel="stylesheet" href="../css/framework7.ios.colors.min.css">
<link rel="stylesheet" href="../css/my-app.css">
<link rel="stylesheet" href="../css/reset.css">
<link rel="stylesheet" href="css/consultation.css">
<script src="../js/jquery-1.7.1.min.js"></script>
<script src="../js/jquery.mobile-1.4.3.js"></script>
<script src="../js/jquery.cookie.js"></script>
<script type="text/javascript" src="../js/framework7.min.js"></script>
<script type="text/javascript" src="../js/my-app.js"></script>
<script src="js/consultation.js"></script>
<script>
    $(function(){
        var code = '';
        var hospital_id = '';
        var department_id = '';
        page_index = 1;
        page_size = 20;
//
        consultationinterface.getCity();
//        获取医院列表
        consultationinterface.hospital_list(code);
//        获取科室列表
        consultationinterface.getdepartment(hospital_id);
//        获取医生列表
        consultationinterface.doctor_list(page_index,page_size,code,hospital_id,department_id,decodeURI('['+$.cookie('doctorid')+']'));
//        指定医生tab下拉
//        $('.appoint-dactor .header-tab .bot-con').on('touchmove', function (event) {
//            event.preventDefault();
//        });
//        $('.appoint-dactor .header-tab .bot-con-region .public-list,.appoint-dactor .header-tab .bot-con-hospital .public-list,.appoint-dactor .header-tab .bot-con-department .public-list').on('touchmove', function (event) {
//            event.stopPropagation();
//        });
        if($.cookie('doctorid_l')<2){
            $('.appoint-dactor .button-next button').css('background','#666');
            $('.appoint-dactor .button-next button').attr('disabled',true);
        }else{
            $('.appoint-dactor .button-next button').css('background','#44b181');
            $('.appoint-dactor .button-next button').attr('disabled',false);
        }
//        地区下拉
        $('.appoint-dactor .header-tab .region').click(function(){
            if($('.appoint-dactor .header-tab .bot-con-region').css('display')=='none'){
                $('.appoint-dactor .header-tab .region img').attr('src','images/icon6.png').parent().siblings().find('img').attr('src','images/icon5.png');
                $('.appoint-dactor .doctor-list').css('position','fixed');
            }else{
                $('.appoint-dactor .header-tab .region img').attr('src','images/icon5.png');
                $('.appoint-dactor .doctor-list').css('position','relative');
            }
            $('.appoint-dactor .header-tab .bot-con-region').toggle();
            $('.appoint-dactor .header-tab .bot-con-region').siblings('.bot-con').hide();
        });
        $('.appoint-dactor .header-tab .bot-con .region-list p').live('click',function(){
            $('.appoint-dactor .doctor-list').css('position','relative');
            code = $(this).data('code');
            var text = $(this).html();
            $('.appoint-dactor .header-tab .region p').html(text);
            if($('.appoint-dactor .header-tab .bot-con-region').css('display')=='none'){
                $('.appoint-dactor .header-tab .region img').attr('src','images/icon6.png').parent().siblings().find('img').attr('src','images/icon5.png');
                $('.appoint-dactor .doctor-list').css('position','fixed');
            }else{
                $('.appoint-dactor .header-tab .region img').attr('src','images/icon5.png');
                $('.appoint-dactor .doctor-list').css('position','relative');
            }
            $('.appoint-dactor .header-tab .bot-con-region').toggle();
            $('.appoint-dactor .header-tab .bot-con-region').siblings('.bot-con').hide();
            $('.appoint-dactor .doctor-list').html('');
            page_index=1
            consultationinterface.doctor_list(page_index,page_size,code,hospital_id,department_id,decodeURI('['+$.cookie('doctorid')+']'));
        });
//        医院下拉
        $('.appoint-dactor .header-tab .hospital').click(function(){
            if($('.appoint-dactor .header-tab .bot-con-hospital').css('display')=='none'){
                $('.appoint-dactor .header-tab .hospital img').attr('src','images/icon6.png').parent().siblings().find('img').attr('src','images/icon5.png');
                $('.appoint-dactor .doctor-list').css('position','fixed');
            }else{
                $('.appoint-dactor .header-tab .hospital img').attr('src','images/icon5.png');
                $('.appoint-dactor .doctor-list').css('position','relative');
            }
            //        获取医院列表
            $('.appoint-dactor .header-tab .bot-con .hospital-list').html('')
            consultationinterface.hospital_list(code);
            $('.appoint-dactor .header-tab .bot-con-hospital').toggle();
            $('.appoint-dactor .header-tab .bot-con-hospital').siblings('.bot-con').hide();
        });
        $(document).on('click','.appoint-dactor .header-tab .bot-con .hospital-list p',function(){
            $('.appoint-dactor .doctor-list').css('position','relative');
            $('.appoint-dactor .header-tab .bot-con .department-list .right').html('');
            $('.appoint-dactor .header-tab .bot-con .department-list .right').append('<p data-id="">全部</p>')
            hospital_id = $(this).data('id');
            var text = $(this).html();
            $('.appoint-dactor .header-tab .hospital p').html(text);
            $('.appoint-dactor .header-tab .bot-con .department-list .left').html('');
            consultationinterface.getdepartment(hospital_id);
            if($('.appoint-dactor .header-tab .bot-con-hospital').css('display')=='none'){
                $('.appoint-dactor .header-tab .hospital img').attr('src','images/icon6.png').parent().siblings().find('img').attr('src','images/icon5.png');
            }else{
                $('.appoint-dactor .header-tab .hospital img').attr('src','images/icon5.png');
            }
            $('.appoint-dactor .header-tab .bot-con-hospital').toggle();
            $('.appoint-dactor .header-tab .bot-con-hospital').siblings('.bot-con').hide();
            $('.appoint-dactor .doctor-list').html('');
            page_index=1
            consultationinterface.doctor_list(page_index,page_size,code,hospital_id,department_id,decodeURI('['+$.cookie('doctorid')+']'));
        });
//        科室下拉
        $('.appoint-dactor .header-tab .bot-con .department-list .right').append('<p data-id="">全部</p>')
        $('.appoint-dactor .header-tab .department').click(function(){
            //        获取子科室
//            consultationinterface.child_getdepartment(0);

            if($('.appoint-dactor .header-tab .bot-con-department').css('display')=='none'){
                $('.appoint-dactor .header-tab .department img').attr('src','images/icon6.png').parent().siblings().find('img').attr('src','images/icon5.png');
            }else{
                $('.appoint-dactor .header-tab .department img').attr('src','images/icon5.png');
            }
            $('.appoint-dactor .header-tab .bot-con-department').toggle();
            $('.appoint-dactor .header-tab .bot-con-department').siblings('.bot-con').hide();
        });
//        科室切换
        var department_list = '.appoint-dactor .header-tab .bot-con .department-list .left p'
        $(document).on('click',department_list,function(){
            $('.appoint-dactor .doctor-list').css('position','relative');
            var index = $(this).index();
            $('.appoint-dactor .header-tab .bot-con .department-list .left p').eq(index).addClass('hover').siblings().removeClass();
            if(index==0){
                $('.appoint-dactor .header-tab .bot-con .department-list .right').html('')
                $('.appoint-dactor .header-tab .bot-con .department-list .right').append('<p data-id="">全部</p>')
            }else{
                consultationinterface.child_getdepartment(index-1);
            }
        });
        $(document).on('click','.appoint-dactor .header-tab .bot-con .department-list .right p',function(){
            department_id = $(this).data('id');
            var text = $(this).html();
            $('.appoint-dactor .header-tab .department p').html(text);
            if($('.appoint-dactor .header-tab .bot-con-department').css('display')=='none'){
                $('.appoint-dactor .header-tab .department img').attr('src','images/icon6.png').parent().siblings().find('img').attr('src','images/icon5.png');
            }else{
                $('.appoint-dactor .header-tab .department img').attr('src','images/icon5.png');
            }
            $('.appoint-dactor .header-tab .bot-con-department').toggle();
            $('.appoint-dactor .header-tab .bot-con-department').siblings('.bot-con').hide();
            $('.appoint-dactor .doctor-list').html('');
            page_index=1
            consultationinterface.doctor_list(page_index,page_size,code,hospital_id,department_id,decodeURI('['+$.cookie('doctorid')+']'));
        });
//    点击选择人物
        $(document).on('click','.appoint-dactor .doctor-list li',function(){
            if($(this).hasClass('icon')){
                $(this).find('.right').find('img').attr('src','images/icon3.png');
                $(this).removeClass('icon');
            }else{
                $(this).find('.right').find('img').attr('src','images/icon4.png');
                $(this).addClass('icon');
            }

            var li_l = $('.appoint-dactor .doctor-list li').length;
            var doctorid = [];
            $.cookie('doctorid_l','',{expires:7,path:'/'});
            $.cookie('doctorid','',{expires:7,path:'/'});
            for(var i=0;i<li_l;i++){
                if($('.appoint-dactor .doctor-list li').eq(i).hasClass('icon')){
                    doctorid.push($('.appoint-dactor .doctor-list li').eq(i).data('id'));
                    $.cookie('doctorid',doctorid,{expires:7,path:'/'});
                    var doctorid_l =  doctorid.length
                    $.cookie('doctorid_l',doctorid_l,{expires:7,path:'/'});
                }
            }
            if($.cookie('doctorid_l')==''){
                doctorid_l = 0
                $.cookie('doctorid_l',doctorid_l,{expires:7,path:'/'});
            }
            console.log($.cookie('doctorid'));
            console.log($.cookie('doctorid_l'));
            if(doctorid_l<2){
                $('.appoint-dactor .button-next button').css('background','#666');
                $('.appoint-dactor .button-next button').attr('disabled',true);
            }else{
                $('.appoint-dactor .button-next button').css('background','#44b181');
                $('.appoint-dactor .button-next button').attr('disabled',false);
            }
        });
//    点击下一步
        $('.appoint-dactor .button-next button').click(function(){
            if($.cookie("is_wechat")==1){
                location.href = 'http://www.ekangjiuyi.net/EKang2.0/hospital_nurse/groupconsultationh-datail.html?reload=1'
            }else{
                $.ajax({
                    type: 'GET',
                    url:  url + '/diagnosis/getcharge/',
                    data: {         // 需要于客户端同步
                        uid: $.cookie("local_userId"),
                        order_id: 0,
                        pay_method:"wx_pub",
                        success_url:'http://www.ekangjiuyi.net/EKang2.0/hospital_nurse/groupconsultationh-datail.html'
                    },
                    dataType: 'jsonp',
                    jsonp: 'callback',
                    success: function (result) {
                        if(result==0){
                            alert('ok')
                        }else{
                            console.log(result.msg)
                        }
                        var url = result.data.location_url;
                        location.href = url;
                    }
                });
            }

//            location.href = '../hospital_nurse/groupconsultationh-datail.html';
        });
//
        var myApp = new Framework7();
        var $$ = Dom7;
//        下拉刷新
        $$('.pull-to-refresh-content').on('refresh', function (e) {
            page_index=1
            $('.infinite-scroll-preloader').html('<div class="preloader"></div>')
            setTimeout(function () {
                $('.appoint-dactor .doctor-list').html('');
                consultationinterface.doctor_list(1,page_size,code,hospital_id,department_id,decodeURI('['+$.cookie('doctorid')+']'));
                myApp.pullToRefreshDone();
            }, 1000);
        });
//        下拉加载
        var loading = false;
        $$('.infinite-scroll').on('infinite', function () {
            // 如果正在加载，则退出
            if (loading) return;
            // 设置flag
            loading = true;
            // 模拟1s的加载过程
            setTimeout(function () {
                // 重置加载flag
                loading = false;
                page_index++
                consultationinterface.doctor_list(page_index,page_size,code,hospital_id,department_id);
            }, 500);
        });
    });
</script>
<body>
<div class="appoint-dactor">
    <div class="header-tab">
        <div class="top">
            <div class="region public">
                <p>城市</p>
                <img src="images/icon5.png">
            </div>
            <div class="hospital public">
                <p>医院</p>
                <img src="images/icon5.png">

            </div>
            <div class="department public">
                <p>科室</p>
                <img src="images/icon5.png">
            </div>
        </div>
        <div class="bot-con bot-con-region">
            <div class="region-list public-list list item-left text-center">
                <p>全部</p>

            </div>
        </div>
        <div class="bot-con bot-con-hospital item-content">
            <div class="hospital-list public-list">
                <p>全部</p>

            </div>
        </div>
        <div class="bot-con bot-con-department">
            <div class="department-list public-list block">
                <div class="left">

                </div>
                <div class="right">

                </div>
            </div>
        </div>
    </div>
    <div class="views">
        <div class="view view-main" data-page="home">
            <div class="pages navbar-through">

                <div data-page="home" class="page">
                    <div class="page-content pull-to-refresh-content infinite-scroll">
                        <div class="pull-to-refresh-layer">
                            <div class="preloader"></div>
                            <div class="pull-to-refresh-arrow"></div>
                        </div>

                        <div class="list-block">
                            <ul class="doctor-list">

                            </ul>
                        </div>
                        <div class="infinite-scroll-preloader">
                            <div class="preloader"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="button-next"><button>下一步</button></div>
</div>

</body>
</html>